Improve error messages for failed command hooks#94
Merged
Conversation
When a rule with a command hook fails, the error message now includes: - Rule name - The exact command that was executed - Exit code - Both stdout and stderr output (when present) - "(no output)" message when command produces no output This replaces the previous minimal error format that only showed stderr.
When a hook script crashes (unhandled exception, import error, etc.), it now outputs a proper JSON response with detailed error information instead of causing a generic "Failed with non-blocking status code" error. Changes: - Add format_hook_error() and output_hook_error() to wrapper.py - Wrap run_hook() in try/except to catch all errors - Add comprehensive error handling in rules_check.py main() - Add tests for error handling functionality The error output includes: - Error type and message - Context (what operation was being performed) - Full traceback for debugging
The try/except in main() was redundant since run_hook() in wrapper.py already catches all exceptions during hook execution. Removed the extra layer, keeping only the if __name__ fallback for early failures.
Ruff auto-fix removed local imports that were already imported at module level.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a rule with a command hook fails, the error message now includes:
This replaces the previous minimal error format that only showed stderr.